//
//  LBXLomoFilter.mm
//  OpenGLGame
//
//  Created by Nguyen Cong Huy on 4/5/13.
//  Copyright (c) 2013 UIT. All rights reserved.
//

#include "LBXLomoFilter.h"
#include "LBToneCurveFilter.h"
#include "LBSharpenFilter.h"
#include "LBSaturationFilter.h"
#include "LBExposureFilter.h"
#include "LBVignetteFilter.h"
#include "LBHueFilter.h"
#include "LBUtils.h"

LBXLomoFilter::LBXLomoFilter(){
    
    exposure = new LBExposureFilter();
    exposure->setExposure(0.1);
    
    toneCurves = new LBToneCurveFilter();
    
    sharpen = new LBSharpenFilter();
    sharpen->setSharpness(0.2);
    
    saturation = new LBSaturationFilter();
    saturation->setSaturation(0.7);
    
    vignette = new LBVignetteFilter();
    vignette->setStart(0.5);
    vignette->setEnd(0.9);
    
    hue = new LBHueFilter();
    hue->setHue(5.0);
    
    
    exposure->addTarget(toneCurves)->addTarget(sharpen)->addTarget(saturation)->addTarget(vignette)->addTarget(hue);
    firstFilter = exposure;
}

LBXLomoFilter::~LBXLomoFilter(){
    outputTexture = 0;
    DELETE_SAFELY(toneCurves);
    DELETE_SAFELY(sharpen);
    DELETE_SAFELY(exposure);
    DELETE_SAFELY(saturation);
    DELETE_SAFELY(vignette);
    DELETE_SAFELY(hue);
}

void LBXLomoFilter::setToneAcvData(unsigned char* toneData){
    toneCurves->setCurveImageData(toneData);
}